package com.huabo.contract.oracle.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.contract.oracle.entity.TblCyhwUnit;
import com.huabo.contract.oracle.entity.TblLegalArbitratsettlement;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huabo
 * @since 2022-03-21
 */
public interface TblLegalArbitratsettlementMapper extends BaseMapper<TblLegalArbitratsettlement> {

    @Select("SELECT * FROM TBL_LEGAL_ARBITRATSETTLEMENT TLA\n" +
            "LEFT JOIN TBL_LEGAL_NEGOTIATEDSETTLEMEN TLN ON TLA.NEGOTIATEINFO = TLN.NEGOTIAID\n" +
            "LEFT JOIN TBL_LEGAL_DISPUTREGISTRATION TLD ON TLN.DISPUINFO = TLD.DISPUTEID" +
            " WHERE ARBITRAID = #{arbitraId}")
    @Options(useGeneratedKeys=true, keyProperty="arbitraid", keyColumn="ARBITRAID")
    TblLegalArbitratsettlement findByArbitraId(Integer arbitraId);

    @Select("SELECT TCU.* FROM TBL_LEGAL_DISPUTREGISTRATION TLD  LEFT JOIN TBL_CYHW_UNIT TCU ON TLD.CONTRACTINFO = TCU.CONTRACTID WHERE TLD.DISPUTEID = #{disputeId}")
    TblCyhwUnit findContractByDisputeId(BigDecimal disputeId);

    @SelectProvider(type=TblLegalArbitratsettlementMapperSqlConfig.class,method="findListByPageInfo")
    List<TblLegalArbitratsettlement> findListByPageInfo(PageInfo<TblLegalArbitratsettlement> pageInfo, TblLegalArbitratsettlement negotia,Integer disputeid);

    @SelectProvider(type=TblLegalArbitratsettlementMapperSqlConfig.class,method="findListByPageInfoCount")
    Integer findListByPageInfoCount(TblLegalArbitratsettlement negotia,Integer disputeid);

    @InsertProvider(type = TblLegalArbitratsettlementMapperSqlConfig.class, method = "saveDiputergistration")
    @Options(useGeneratedKeys=true, keyProperty="arbitraid", keyColumn="ARBITRAID")
    void saveDiputergistration(TblLegalArbitratsettlement arbitrat);

    @Delete("DELETE FROM TBL_LEGAL_ARBITRATSETTLEMENT WHERE ARBITRAID = #{arbitrat}")
    void removeLegalNegotiatedSettlemen(Integer arbitrat);

    @UpdateProvider(type=TblLegalArbitratsettlementMapperSqlConfig.class,method="modifyNegotiatedSettlement")
    @Options(useGeneratedKeys=true, keyProperty="arbitraid", keyColumn="ARBITRAID")
    void modifyNegotiatedSettlement(TblLegalArbitratsettlement oldArbitrat);

    @Select("SELECT * FROM TBL_LEGAL_ARBITRATSETTLEMENT TLA\n" +
            "LEFT JOIN TBL_LEGAL_NEGOTIATEDSETTLEMEN TLN ON TLA.NEGOTIATEINFO = TLN.NEGOTIAID\n" +
            "LEFT JOIN TBL_LEGAL_DISPUTREGISTRATION TLD ON TLN.DISPUINFO = TLD.DISPUTEID\n" +
            "WHERE ARBITRAID = #{arbitraId}")
    TblLegalArbitratsettlement findByarbitraid(Integer arbitraId);
}
